<include file="Public:header"/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
<!-- form 样式 -->
<link href="__STATIC__/form/style.css" rel='stylesheet' type='text/css' />
<link href="__STATIC__/form/font-awesome.css" rel="stylesheet"> 

<link href="__STATIC__/form/animate.css" rel="stylesheet" type="text/css" media="all">
<link href="__STATIC__/form/add.css" rel="stylesheet" type="text/css" media="all">


<div class="form-grids row widget-shadow" data-example-id="basic-forms"> 

	<div class="form-body">
		<!-- <form action='' method='post' enctype="multipart/form-data" onsubmit='return check()' class="form-horizontal">  -->
			<div class="form-group">
				<label for="exampleInputEmail1" class="col-md-2 control-label">角色名称</label>
				<div class="col-md-10">
					<input type="text" id='name' name='name' class="form-control" id="exampleInputEmail1" value="{$info.name}" placeholder="请输入角色名称">
				</div>
			</div>
			<div class="form-group">
				<label for="exampleInputEmail1" class="col-md-2 control-label">角色描述</label>
				<div class="col-md-10">
					<input type="text" id='description' name='description' class="form-control" id="exampleInputEmail1" value="{$info.description}" placeholder="请输入角色描述">
				</div>
			</div>
			<div class="form-group">
				<div class="col-md-offset-2 col-md-10">
					<input type="hidden" class="admin_role_id" value="{$info.id}">
					<button type="submit" class="sub" class="btn btn-primary">提交</button>
				</div>
			</div>
		<!-- </form>  -->
	</div>
</div>
<script src="__STATIC__/news/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/components/layui/layui/layui.all.js"></script>
<script type="text/javascript">
// function check(){
	$(".sub").click(function(){
		var admin_role_id = $('.admin_role_id').val();
		var name = $('#name').val();
		if(name == ''){
			alert('请输入角色名称');return false;
		}
		var description = $('#description').val();
		if(admin_role_id > 0){
			
			//修改
			$.ajax({
			    url:"{:U('System/edit_role')}",
			    data:{admin_role_id:admin_role_id,role_name:name,description:description},
			    type:"POST",
			    dataType:"json",
			    success:function(ret){
			        if(ret.value==2){
			            layer.msg(ret.msg,{time:3000});
			            layer.close('layer');
			        }else{
			            layer.msg(ret.msg,{time:3000});
			        }
			    }
			})
		}else{
			//新增
			$.ajax({
			    url:"{:U('System/add_role')}",
			    data:{role_name:name,description:description},
			    type:"POST",
			    dataType:"json",
			    success:function(ret){
			        if(ret.value==2){
			            layer.msg(ret.msg,{time:3000});
			            layer.close('layer');
			        }else{
			            layer.msg(ret.msg,{time:3000});
			        }
			    }
			})
		}
	})
	
	
// }
	
</script>

<include file="Public:footer"/>